<template>
	<div>
		<tableIndex
			:tableData="state.tableData"
			:tableHead="state.tableHead"
			:isIndex="true"
			:height="'500'"
			:page="state.page"
			:not-search="true"
			@page-change="pageChange"
		>
			<template #operate>
				<el-table-column label="操作" align="center" fixed="right">
					<template #default="{ row }">
						<el-button
							size="small"
							class="button_edit"
							@click="lookItemHandler(row)"
							type="primary"
							>查看</el-button
						>
					</template>
				</el-table-column>
			</template>
		</tableIndex>

		<!-- 会议弹框 -->
		<DrawerNanme ref="DrawerNanmeRef"></DrawerNanme>
	</div>
</template>
<script setup>
import "@/views/constructionProjectManage/static/button.scss";
import tableIndex from "@/components/table/index.vue";
import { ref, reactive, onMounted, computed } from "vue";
import { assetsApi } from "@/api/assets";
import { useRouter, useRoute } from "vue-router";
import DrawerNanme from "./DrawerNanme.vue";

import { projectApi, projectListApi, qualitySupervision } from "@/api/project";

const props = defineProps({
	form: {
		type: Object,
		default: {
			projectName: "",
			dealDepartmentId: "",
			projectId: "",
		},
	},
});
const state = reactive({
	centerDialogVisible: false,
	activeName: "0",
	projectNames: "项目名称选择",
	page: {
		page: 1,
		pageSize: 50,
		total: 0,
	},
	areaTypeOptionsArr: [],
	selectList: [],
	tableData: [],
	tableHead: [
		{
			prop: "projectName",
			label: "项目名称",
		},
		{
			prop: "problemCategory",
			label: "问题分类",
		},
		{
			prop: "problemType",
			label: "问题类型",
		},
		{
			prop: "dealStatus",
			label: "状态",
			formatter: (row) => {
				let str = "";
				switch (row.dealStatus) {
					case -1:
						str = "待处理";
						break;
					case 1:
						str = "处理中";
						break;
					case 2:
						str = "已处理";
						break;

					case 3:
						str = "已关闭";
						break;

					default:
						str = "-";
						break;
				}
				return str;
			},
		},
		{
			prop: "applyUserName",
      label: "发起责任人",
      width: 100,
		},
		{
			prop: "problemDescription",
			label: "问题描述",
		},
		{
			prop: "dealDepartmentName",
			label: "处理部门",
		},
		{
			prop: "dealUserName",
			label: "处理人",
		},
		{
			prop: "deadline",
      label: "截止完成时间",
      width: 120,
		},
		{
			prop: "createTime",
			label: "创建时间",
		},
	],
});
const profercencedialog = ref(null);
const formInline = reactive({});
const pageChange = (e) => {
	state.page = e.page;
	state.pageSize = e.limit;
	getPage();
};
const DrawerNanmeRef = ref(null);
const lookItemHandler = (e) => {
	// alert('打开质量监督弹框')
	DrawerNanmeRef.value.state.centerDialogVisible = true;
	DrawerNanmeRef.value.state.qualityProblemId = e.qualityProblemId;
	DrawerNanmeRef.value.state.dealStatus = e.dealStatus;
};

const getPage = () => {
	console.log("props.form", props.form);
	qualitySupervision
		.getPage({
			pageNum: state.page.page,
			pageSize: state.page.pageSize,
			param: {
				...props.form,
			},
		})
		.then((res) => {
			if (res.code == 200) {
				state.tableData = res.data.content;
				state.page.total = res.data.totalSize;
				console.log(res);
			}
		});
};

onMounted(() => {
	getPage();
});
</script>
<style scoped lang="scss">
@import "@/assets/general_style/dialog.scss";
</style>
